package com.yatu.codegen.data;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.yatu.codegen.db.DBService;
import com.yatu.codegen.db.DBServiceImpl;

public class DataServiceImpl implements DataService {

	/**
	 * 根据表名获取模板要用的Map型数据 (带有列信息)
	 * 
	 * @param tableName
	 * @return
	 * @throws SQLException
	 */
	public Map<String, Object> getDbTemplateData(String tableName, String packageName, String className)
			throws SQLException {
		DBService dbService = new DBServiceImpl();
		Map<String, Object> templateData = new HashMap<String, Object>();
		templateData.put("tableName", tableName);
		templateData.put("properties", dbService.getAllColums(tableName));
		templateData.put("className", className);
		templateData.put("package", packageName);
		return templateData;
	}

	@Override
	public Map<String, Object> getDbTemplateData(String tableName, Map<String, Object> datas) throws SQLException {
		datas.put("properties", new DBServiceImpl().getAllColums(tableName));
		datas.put("tableName", tableName);
		return datas;
	}

}
